{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "c:\\users\\administrator\\anaconda3\\lib\\site-packages\\socks.py:58: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working\n",
      "  from collections import Callable\n",
      "c:\\users\\administrator\\anaconda3\\lib\\site-packages\\win32\\lib\\pywintypes.py:2: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses\n",
      "  import imp, sys, os\n",
      "c:\\users\\administrator\\anaconda3\\lib\\site-packages\\pkg_resources\\_vendor\\pyparsing.py:943: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working\n",
      "  collections.MutableMapping.register(ParseResults)\n",
      "c:\\users\\administrator\\anaconda3\\lib\\site-packages\\pkg_resources\\_vendor\\pyparsing.py:3245: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working\n",
      "  elif isinstance( exprs, collections.Iterable ):\n",
      "c:\\users\\administrator\\anaconda3\\lib\\site-packages\\scipy\\linalg\\__init__.py:212: DeprecationWarning: The module numpy.dual is deprecated.  Instead of using dual, use the functions directly from numpy or scipy.\n",
      "  from numpy.dual import register_func\n",
      "c:\\users\\administrator\\anaconda3\\lib\\site-packages\\scipy\\special\\orthogonal.py:81: DeprecationWarning: `np.int` is a deprecated alias for the builtin `int`. To silence this warning, use `int` by itself. Doing this will not modify any behavior and is safe. When replacing `np.int`, you may wish to use e.g. `np.int64` or `np.int32` to specify the precision. If you wish to review your current use, check the release note link for additional information.\n",
      "Deprecated in NumPy 1.20; for more details and guidance: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations\n",
      "  from numpy import (exp, inf, pi, sqrt, floor, sin, cos, around, int,\n",
      "c:\\users\\administrator\\anaconda3\\lib\\site-packages\\scipy\\sparse\\sputils.py:16: DeprecationWarning: `np.typeDict` is a deprecated alias for `np.sctypeDict`.\n",
      "  supported_dtypes = [np.typeDict[x] for x in supported_dtypes]\n",
      "c:\\users\\administrator\\anaconda3\\lib\\site-packages\\matplotlib\\rcsetup.py:20: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working\n",
      "  from collections import Iterable, Mapping\n",
      "c:\\users\\administrator\\anaconda3\\lib\\site-packages\\matplotlib\\colors.py:53: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working\n",
      "  from collections import Sized\n",
      "2025-04-28 16:55:20,180-WARNING: type object 'QuantizationTransformPass' has no attribute '_supported_quantizable_op_type'\n",
      "2025-04-28 16:55:20,181-WARNING: If you want to use training-aware and post-training quantization, please use Paddle >= 1.8.4 or develop version\n",
      "usage: paddlex [-h] [--model_dir MODEL_DIR] [--save_dir SAVE_DIR] [--version]\n",
      "               [--export_inference] [--data_conversion] [--source SOURCE]\n",
      "               [--to TO] [--pics PICS] [--annotations ANNOTATIONS]\n",
      "               [--fixed_input_shape FIXED_INPUT_SHAPE] [--split_dataset]\n",
      "               [--format FORMAT] [--dataset_dir DATASET_DIR]\n",
      "               [--val_value VAL_VALUE] [--test_value TEST_VALUE]\n",
      "paddlex: error: unrecognized arguments: __model_dir=./data/best_model\n"
     ]
    }
   ],
   "source": [
    "!paddlex --export __model_dir=./data/best_model --save_dir=./inference_model"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "'unzip' 不是内部或外部命令，也不是可运行的程序\n",
      "或批处理文件。\n"
     ]
    }
   ],
   "source": [
    "!unzip -oq best_model.zip"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2025-04-28 16:57:11 [ERROR]\tmodel_dir './data/best_model' does not exists!\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "c:\\users\\administrator\\anaconda3\\lib\\site-packages\\socks.py:58: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working\n",
      "  from collections import Callable\n",
      "c:\\users\\administrator\\anaconda3\\lib\\site-packages\\win32\\lib\\pywintypes.py:2: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses\n",
      "  import imp, sys, os\n",
      "c:\\users\\administrator\\anaconda3\\lib\\site-packages\\pkg_resources\\_vendor\\pyparsing.py:943: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working\n",
      "  collections.MutableMapping.register(ParseResults)\n",
      "c:\\users\\administrator\\anaconda3\\lib\\site-packages\\pkg_resources\\_vendor\\pyparsing.py:3245: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working\n",
      "  elif isinstance( exprs, collections.Iterable ):\n",
      "c:\\users\\administrator\\anaconda3\\lib\\site-packages\\scipy\\linalg\\__init__.py:212: DeprecationWarning: The module numpy.dual is deprecated.  Instead of using dual, use the functions directly from numpy or scipy.\n",
      "  from numpy.dual import register_func\n",
      "c:\\users\\administrator\\anaconda3\\lib\\site-packages\\scipy\\special\\orthogonal.py:81: DeprecationWarning: `np.int` is a deprecated alias for the builtin `int`. To silence this warning, use `int` by itself. Doing this will not modify any behavior and is safe. When replacing `np.int`, you may wish to use e.g. `np.int64` or `np.int32` to specify the precision. If you wish to review your current use, check the release note link for additional information.\n",
      "Deprecated in NumPy 1.20; for more details and guidance: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations\n",
      "  from numpy import (exp, inf, pi, sqrt, floor, sin, cos, around, int,\n",
      "c:\\users\\administrator\\anaconda3\\lib\\site-packages\\scipy\\sparse\\sputils.py:16: DeprecationWarning: `np.typeDict` is a deprecated alias for `np.sctypeDict`.\n",
      "  supported_dtypes = [np.typeDict[x] for x in supported_dtypes]\n",
      "c:\\users\\administrator\\anaconda3\\lib\\site-packages\\matplotlib\\rcsetup.py:20: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working\n",
      "  from collections import Iterable, Mapping\n",
      "c:\\users\\administrator\\anaconda3\\lib\\site-packages\\matplotlib\\colors.py:53: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working\n",
      "  from collections import Sized\n",
      "2025-04-28 16:57:10,542-WARNING: type object 'QuantizationTransformPass' has no attribute '_supported_quantizable_op_type'\n",
      "2025-04-28 16:57:10,542-WARNING: If you want to use training-aware and post-training quantization, please use Paddle >= 1.8.4 or develop version\n"
     ]
    }
   ],
   "source": [
    "!paddlex --export_inference --model_dir=./data/best_model --save_dir=./inference_model"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "C:\\Users\\Administrator\\Anaconda3\\lib\\site-packages\\socks.py:58: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working\n",
      "  from collections import Callable\n",
      "C:\\Users\\Administrator\\Anaconda3\\lib\\site-packages\\scipy\\linalg\\__init__.py:212: DeprecationWarning: The module numpy.dual is deprecated.  Instead of using dual, use the functions directly from numpy or scipy.\n",
      "  from numpy.dual import register_func\n",
      "C:\\Users\\Administrator\\Anaconda3\\lib\\site-packages\\scipy\\special\\orthogonal.py:81: DeprecationWarning: `np.int` is a deprecated alias for the builtin `int`. To silence this warning, use `int` by itself. Doing this will not modify any behavior and is safe. When replacing `np.int`, you may wish to use e.g. `np.int64` or `np.int32` to specify the precision. If you wish to review your current use, check the release note link for additional information.\n",
      "Deprecated in NumPy 1.20; for more details and guidance: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations\n",
      "  from numpy import (exp, inf, pi, sqrt, floor, sin, cos, around, int,\n",
      "C:\\Users\\Administrator\\Anaconda3\\lib\\site-packages\\scipy\\sparse\\sputils.py:16: DeprecationWarning: `np.typeDict` is a deprecated alias for `np.sctypeDict`.\n",
      "  supported_dtypes = [np.typeDict[x] for x in supported_dtypes]\n",
      "C:\\Users\\Administrator\\Anaconda3\\lib\\site-packages\\matplotlib\\colors.py:53: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working\n",
      "  from collections import Sized\n",
      "2025-04-28 17:01:36,655-WARNING: type object 'QuantizationTransformPass' has no attribute '_supported_quantizable_op_type'\n",
      "2025-04-28 17:01:36,657-WARNING: If you want to use training-aware and post-training quantization, please use Paddle >= 1.8.4 or develop version\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2025-04-28 17:01:37 [ERROR]\tmodel_dir './inference_model' does not exists!\n"
     ]
    },
    {
     "ename": "SystemExit",
     "evalue": "-1",
     "output_type": "error",
     "traceback": [
      "An exception has occurred, use %tb to see the full traceback.\n",
      "\u001b[1;31mSystemExit\u001b[0m\u001b[1;31m:\u001b[0m -1\n"
     ]
    }
   ],
   "source": [
    "import paddlex as pdx\n",
    "predictor =pdx.deploy.Predictor('./inference_model')\n",
    "result = predictor.predict( 'data/garbage/paper/paper1.jpg')\n",
    "print(result)\n",
    "category = result[0]['category']\n",
    "category"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2025-04-28 17:05:15 [ERROR]\tmodel_dir './inference_model' does not exists!\n"
     ]
    },
    {
     "ename": "SystemExit",
     "evalue": "-1",
     "output_type": "error",
     "traceback": [
      "An exception has occurred, use %tb to see the full traceback.\n",
      "\u001b[1;31mSystemExit\u001b[0m\u001b[1;31m:\u001b[0m -1\n"
     ]
    }
   ],
   "source": [
    "import paddlex as pdx\n",
    "predictor=pdx.deploy.Predictor( './inference_model')\n",
    "image_list = [ 'data/garbage/paper/paper10.jpg','data/garbage/plastic/plastic10.jpg', 'data/garbage/glass/glass10.jpg']\n",
    "result = predictor.batch_predict(image_list=image_list)\n",
    "result"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "ename": "SyntaxError",
     "evalue": "invalid syntax (<ipython-input-6-823bb6ca45a6>, line 4)",
     "output_type": "error",
     "traceback": [
      "\u001b[1;36m  File \u001b[1;32m\"<ipython-input-6-823bb6ca45a6>\"\u001b[1;36m, line \u001b[1;32m4\u001b[0m\n\u001b[1;33m    TENSORRT_DIR=/home/dlinano/projects/TensoRT/\u001b[0m\n\u001b[1;37m                 ^\u001b[0m\n\u001b[1;31mSyntaxError\u001b[0m\u001b[1;31m:\u001b[0m invalid syntax\n"
     ]
    }
   ],
   "source": [
    "WITH_GPU=OFF\n",
    "WITH_MKL=OFF\n",
    "WITH_TENSORRT=OFF\n",
    "TENSORRT_DIR=/home/dlinano/projects/TensoRT/\n",
    "PADDLE_DIR=/home/dlinano/projects/fluid_inference\n",
    "WITH_STATIC_LIB=OFF\n",
    "CUDA_LIB=/sur/local/cuda/lib64\n",
    "CUDNN_LIB=/usr/local/cuda/lib64\n",
    "rm -rf build\n",
    "mkdir -p bulid\n",
    "cd build\n",
    "cmake..\\\n",
    "    -DWITH_GPU=${WITH_GPU}\\\n",
    "    -DWITH_MKL=${WITH_MKL}\\\n",
    "    -DWITH_TENSORRT=${WITH_TENSORRT}\\\n",
    "    -DWITH_ENCRYPTION=${WITH_ENCRYPTION}\\\n",
    "    -DTENSORRT_DIR=${TENSORRT_DIR}\\\n",
    "    -DPADDLE_DIR=${PADDLE_DIR}\\\n",
    "    -DWITH_STATIC_LIB=${WITH_STATIC_LIB}\\\n",
    "    -DCUDA_LIB=${CUDA_LIB}\\\n",
    "    -DCUDNN_LIB=${CUDNN_LIB}\n",
    "make"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
